﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="AnnouncementDetail.aspx.cs" Inherits="AnnouncementDetail" %>

<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.HTMLEditor" TagPrefix="obout" %>
<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.HTMLEditor.ToolbarButton" TagPrefix="obout" %>
<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.HTMLEditor.Popups" TagPrefix="obout" %>
<%@ Register Src="../UserControls/ucDateTimePicker.ascx" TagName="ucDateTimePicker" TagPrefix="Kerry" %>
<%@ Register Src="~/UserControls/ucHtmlEditor.ascx" TagPrefix="Kerry" TagName="ucHtmlEditor" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="Server">

    
  
</asp:Content>
<asp:Content runat="server" ID="content1" ContentPlaceHolderID="MainContent">
    <script src="../Scripts/bas_error.js"></script>
    <script src="../Scripts/GridDataBind.js"></script>
    <script src="../Scripts/scroll.js"></script>
    <script type="text/javascript" src="Scripts/AnnouncementDetail.js"></script>
    
  <asp:Button ID="btn_Update" runat="server" CausesValidation="False" CommandName="Update" Text="存檔" OnClientClick="setvalue(); return check();" OnClick="btn_Update_Click" />
  <asp:Button ID="btn_Insert" runat="server" CausesValidation="True" CommandName="Insert" Text="新增" OnClientClick="setvalue(); return check();" OnClick="btn_Insert_Click" />
  <asp:Button ID="btn_Delete" runat="server" CausesValidation="False" CommandName="Delete" Text="刪除" OnClientClick="setvalue(); return check(); return confirm('是否確定刪除?');" OnClick="btn_Delete_Click" />
  <asp:Button ID="btn_Exit" runat="server" CausesValidation="False" Text="離開" OnClientClick="TRANS();return true;" OnClick="btn_Exit_Click" />
  <asp:Label ID="lbl_Message" runat="server" EnableViewState="false"></asp:Label>
  
  <br />
  <asp:Panel ID="PanelDetail" runat="server">
    <table class="ConditionTable">
      <tr>
        <th colspan="2">公告欄明細資訊 </th>
      </tr>
        <tr>
          <td style="width:10%">公告代號：</td>
          <td style="width:90%">
            <asp:TextBox ID="txt_BULLETIN_ID" runat="server" Enabled="false" />
          </td>
        </tr>
        <tr>
          <td>公告對象：</td>
          <td>
            
                
                  <asp:Label ID="lblCompany" runat="server" Text="公司"></asp:Label>
                ：<%--<asp:DropDownList ID="ddlcompany" onchange="getDept_Down(event,this.id)"  runat="server">
                    <asp:ListItem Text="-All-" Value="ALL"></asp:ListItem>
                 </asp:DropDownList>--%>
              
              <select id="ddlcompany" onchange="getDept_Down(this.id)">
                  <option value="ALL">-All-</option>
              </select>
              <asp:HiddenField ID="hidcompany" runat="server" />
                &nbsp;營總：<%--<asp:DropDownList ID="ddlbu" onchange="getDept_Down(event,this.id)" runat="server" >    
                            <asp:ListItem Text="-All-" Value="ALL"></asp:ListItem>
                         </asp:DropDownList>--%>
                <select id="ddlbu" onchange="getDept_Down(this.id)">
                  <option value="ALL">-All-</option>
              </select>
              <asp:HiddenField ID="hidbu" runat="server" />
                &nbsp;處級：<%--<asp:DropDownList ID="ddlzone" onchange="getDept_Down(event,this.id)" runat="server">
                    <asp:ListItem Text="-All-" Value="ALL"></asp:ListItem>
                         </asp:DropDownList>--%>
                <select id="ddlzone" onchange="getDept_Down(this.id)">
                  <option value="ALL">-All-</option>
              </select>
              <asp:HiddenField ID="hidzone" runat="server" />
                
                區級：<%--<asp:DropDownList ID="ddlAREA" onchange="getDept_Down(event,this.id)" runat="server">
                    <asp:ListItem Text="-All-" Value="ALL"></asp:ListItem>
                   </asp:DropDownList>--%>
                   <select id="ddlAREA" onchange="getDept_Down(this.id)">
                  <option value="ALL">-All-</option>
              </select>
              <asp:HiddenField ID="hidAREA" runat="server" />

                所級：<%--<asp:DropDownList ID="ddlDept" runat="server" >
                    <asp:ListItem Text="-All-" Value="ALL"></asp:ListItem>
                   </asp:DropDownList>--%>
              <select id="ddlDept" onchange="getDept_Down(this.id)">
                  <option value="ALL">-All-</option>
              </select>
              <asp:HiddenField ID="hidDept" runat="server" />
              <asp:Button ID="btnAdd" runat="server" Text="新增條件" OnClientClick ="return btn_Add_Condition()"  />
              <br />
              <asp:HiddenField ID="hidseq_C" runat="server" />
              <asp:HiddenField ID="hidcompany_C" runat="server" />
              <asp:HiddenField ID="hidbu_C" runat="server" />
              <asp:HiddenField ID="hidzone_C" runat="server" />
              <asp:HiddenField ID="hidarea_C" runat="server" />
              <asp:HiddenField ID="hiddept_C" runat="server" />

              <asp:HiddenField ID="hidcompany_C_T" runat="server" />
              <asp:HiddenField ID="hidbu_C_T" runat="server" />
              <asp:HiddenField ID="hidzone_C_T" runat="server" />
              <asp:HiddenField ID="hidarea_C_T" runat="server" />
              <asp:HiddenField ID="hiddept_C_T" runat="server" />

              <table id="tabCondition"  >
                  
              </table>
             
          </td>
        </tr>
        
        <tr>
          <td>公告日期起迄：</td>
          <td>
            <asp:TextBox ID="txt_START_DATE" runat="server" />
            <ajaxToolkit:CalendarExtender ID="txtDate_CalendarExtender" runat="server"
              Enabled="True" Format="yyyyMMdd" PopupButtonID="ImageCal" TargetControlID="txt_START_DATE">
            </ajaxToolkit:CalendarExtender>
            <asp:Image ID="ImageCal" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png" />
              <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="check_date"
                ControlToValidate="txt_START_DATE" ForeColor="Red" Display="Dynamic"  ValidateEmptyText="True"></asp:CustomValidator>--%>
              <asp:RegularExpressionValidator ID="REV" runat="server" Display="Dynamic" ErrorMessage="日期格式有誤"
              SetFocusOnError="True" ForeColor="Red" ControlToValidate="txt_START_DATE" ValidationExpression="\d{8}" />
            <asp:RequiredFieldValidator ID="RV_Start" runat="server" Display="Dynamic" ControlToValidate="txt_START_DATE"
              ErrorMessage="起始日期不能空白" ForeColor="Red" SetFocusOnError="True" />
            <asp:CompareValidator ID="CV" runat="server" ControlToValidate="txt_START_DATE" Display="Dynamic" ErrorMessage="起始日不得小於今日" ForeColor="Red" Operator="GreaterThanEqual" SetFocusOnError="True" Type="Integer"></asp:CompareValidator>
            &nbsp;~
            <Kerry:ucDateTimePicker ID="txt_END_DATE" runat="server" />
              <asp:HiddenField ID="hidSYSDATE" runat="server" />
            &nbsp;</td>
          <td></td>
        </tr>
        <tr>
          <td>公告啟用：</td>
          <td>
            <asp:DropDownList ID="ddl_Status" runat="server">
              <asp:ListItem>Y</asp:ListItem>
              <asp:ListItem>N</asp:ListItem>
            </asp:DropDownList>
          </td>
        </tr>
     
        <tr>
            <td>公告內容：</td>
            <td>
                <table>
                    <tr>
                        <td>
                            <asp:RadioButton ID="rdo_TW" GroupName="LNG" Text ="繁體中文" runat="server" />
                             <asp:RadioButton ID="rdo_GB" GroupName="LNG" Text ="簡體中文" runat="server" />
                             <asp:RadioButton ID="rdo_EN" GroupName="LNG" Text ="英文" runat="server" />       
                        </td>
                    </tr>
                </table>
                <div id="tabs-1">
                
               <br />
                大綱：<asp:Label ID="lbl_text" runat="server" Text="(注意：大綱最大長度：100字)" />
                <br />
                <asp:TextBox ID="txt_BULLETIN_TEXT" runat="server" Width="100%" MaxLength="100" />
                <asp:HiddenField ID="hid_BULLETIN_TEXT_TW" runat="server" />
                <asp:HiddenField ID="hid_BULLETIN_TEXT_EN" runat="server" />
                <asp:HiddenField ID="hid_BULLETIN_TEXT_GB" runat="server" />
                    <br />
                內容：<asp:Label ID="lbl_spec_tw" runat="server" Text="" />
                <br />
                <Kerry:ucHtmlEditor runat="server" ID="txt_BULLETIN_SPEC" />
                  <asp:HiddenField ID="hid_BULLETIN_SPEC_TW" runat="server" />
                  <asp:HiddenField ID="hid_BULLETIN_SPEC_EN" runat="server" />
                  <asp:HiddenField ID="hid_BULLETIN_SPEC_GB" runat="server" />
                  <asp:HiddenField ID="hid_FLAG" runat="server" />
              </div>
            </td>
        </tr>    
            
        <tr>
          <td>註解：</td>
          <td>
            <asp:TextBox ID="txt_REMARK" runat="server" Width="100%" Rows="3" TextMode="MultiLine" MaxLength="250" />
          </td>
        </tr>
        <tr>
          <td>附件上傳：</td>
          <td>
            <asp:Panel ID="FileUploadHost" runat="server">
              <asp:FileUpload ID="FileUpload_Attachments" runat="server" AllowMultiple="true" Width="100%" />
            </asp:Panel>
            <asp:GridView ID="GVFileLists" SkinID="gvSkin" runat="server"
              AutoGenerateColumns="False"
              OnRowDeleting="GVFileLists_RowDeleting" OnRowDataBound="GVFileLists_RowDataBound">
              <Columns>
                <asp:TemplateField ShowHeader="False">
                  <ItemTemplate>
                    <asp:ImageButton ID="IB_Delete" runat="server" Width="24px"
                      CausesValidation="False" CommandName="Delete"
                      ImageUrl="~/Images/delete-icon.png" Text="刪除" ToolTip="Delete" />
                    <asp:Label ID="lbl_FullName" runat="server" Text='<%# Bind("FullName") %>' Visible="false" />
                    <asp:Label ID="lbl_DirectoryName" runat="server" Text='<%# Bind("DirectoryName") %>' Visible="false" />
                  </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Name" HeaderText="檔案名稱" SortExpression="Name" />
                <asp:BoundField DataField="Extension" HeaderText="副檔名" SortExpression="Extension" />
                <asp:BoundField DataField="CreationTime" HeaderText="建立時間" SortExpression="CreationTime" />
                <asp:TemplateField HeaderText="Download">
                  <ItemTemplate>
                    <asp:HyperLink ID="Link_Download" runat="server" Text="Download" />
                  </ItemTemplate>
                </asp:TemplateField>
              </Columns>
            </asp:GridView>

          </td>
        </tr>
        <tr>
          <td colspan="2">
            <asp:TextBox ID="txt_CRT_ID" runat="server" Visible="false" />
            <asp:TextBox ID="txt_CRT_DATE" runat="server" Visible="false" />
            <asp:TextBox ID="txt_CRT_TIME" runat="server" Visible="false" />
            <asp:TextBox ID="txt_UPD_ID" runat="server" Visible="false" />
            <asp:TextBox ID="txt_UPD_DATE" runat="server" Visible="false" />
            <asp:TextBox ID="txt_UPD_TIME" runat="server" Visible="false" />
          </td>
        </tr>
      
    </table>
  </asp:Panel>
    
    <script type="text/javascript">
        function setvalue() {
            //存檔前將畫面的值放入hidden 
            var editPanel = $find("<%= txt_BULLETIN_SPEC.editor_ID %>").get_editPanel();
            var _content = htmlEncode(editPanel.get_content());
            var _BULLETIN_TEXT = htmlEncode($("#MainContent_txt_BULLETIN_TEXT").val());
            
            switch ($("#MainContent_hid_FLAG").val()) {
                case "TW":
                    $("#MainContent_hid_BULLETIN_SPEC_TW").val(_content);
                    $("#MainContent_hid_BULLETIN_TEXT_TW").val(_BULLETIN_TEXT);
                    break;
                case "EN":
                    $("#MainContent_hid_BULLETIN_SPEC_EN").val(_content);
                    $("#MainContent_hid_BULLETIN_TEXT_EN").val(_BULLETIN_TEXT);
                    break;
                case "GB":
                    $("#MainContent_hid_BULLETIN_SPEC_GB").val(_content);
                    $("#MainContent_hid_BULLETIN_TEXT_GB").val(_BULLETIN_TEXT);
                    break;
                default:
                    break;
            }
        }
        $(function () {
            $("input[id*='rdo_TW']").click(function () {
                if ($("#MainContent_hid_FLAG").val() != "TW") {
                    var editPanel = $find("<%= txt_BULLETIN_SPEC.editor_ID %>").get_editPanel();
                    var _content = htmlEncode(editPanel.get_content());
                    var _BULLETIN_TEXT = htmlEncode($("#MainContent_txt_BULLETIN_TEXT").val());
                    if ($("#MainContent_hid_FLAG").val() == "EN") {
                        $("#MainContent_hid_BULLETIN_SPEC_EN").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_EN").val(_BULLETIN_TEXT);
                    }
                    else {
                        $("#MainContent_hid_BULLETIN_SPEC_GB").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_GB").val(_BULLETIN_TEXT);
                    }
                    $("#MainContent_hid_FLAG").val("TW");
                    var shtml = $("#MainContent_hid_BULLETIN_SPEC_TW").val();
                    editPanel.set_content(htmlDecode(shtml));
                    _BULLETIN_TEXT = htmlDecode($("#MainContent_hid_BULLETIN_TEXT_TW").val());
                    $("#MainContent_txt_BULLETIN_TEXT").val(_BULLETIN_TEXT);
                    $("span[id*='lbl_text']").text("(注意：大綱最大長度：100字) ");
                }
            });
        });

        $(function () {
            $("input[id*='rdo_GB']").click(function () {
                if ($("#MainContent_hid_FLAG").val() != "GB") {
                    var editPanel = $find("<%= txt_BULLETIN_SPEC.editor_ID %>").get_editPanel();
                    var _content = htmlEncode(editPanel.get_content());
                    var _BULLETIN_TEXT = htmlEncode($("#MainContent_txt_BULLETIN_TEXT").val());
                    //alert(_content);
                    if ($("#MainContent_hid_FLAG").val() == "EN") {
                        $("#MainContent_hid_BULLETIN_SPEC_EN").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_EN").val(_BULLETIN_TEXT);
                    }
                    else {
                        //alert(htmlEncode(_content));
                        $("#MainContent_hid_BULLETIN_SPEC_TW").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_TW").val(_BULLETIN_TEXT);
                    }
                    $("#MainContent_hid_FLAG").val("GB");
                    var shtml = $("#MainContent_hid_BULLETIN_SPEC_GB").val();
                    //alert(shtml);
                    editPanel.set_content(htmlDecode(shtml));
                    _BULLETIN_TEXT = htmlDecode($("#MainContent_hid_BULLETIN_TEXT_GB").val());
                    $("#MainContent_txt_BULLETIN_TEXT").val(_BULLETIN_TEXT);
                    $("span[id*='lbl_text']").text("(注意：大纲最大长度：100字) ");
                }
            });
        });

        $(function () {
            $("input[id*='rdo_EN']").click(function () {
                if ($("#MainContent_hid_FLAG").val() != "EN") {
                    var editPanel = $find("<%= txt_BULLETIN_SPEC.editor_ID %>").get_editPanel();
                    var _content = htmlEncode(editPanel.get_content());
                    var _BULLETIN_TEXT = htmlEncode($("#MainContent_txt_BULLETIN_TEXT").val());
                    if ($("#MainContent_hid_FLAG").val() == "TW") {
                        $('<div/>').text(_content).html();
                        $("#MainContent_hid_BULLETIN_SPEC_TW").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_TW").val(_BULLETIN_TEXT);
                    }
                    else {
                        $("#MainContent_hid_BULLETIN_SPEC_GB").val(_content);
                        $("#MainContent_hid_BULLETIN_TEXT_GB").val(_BULLETIN_TEXT);
                    }
                    $("#MainContent_hid_FLAG").val("EN");
                    
                    var shtml = $("#MainContent_hid_BULLETIN_SPEC_EN").val();
                    editPanel.set_content(htmlDecode(shtml));
                    _BULLETIN_TEXT = htmlDecode($("#MainContent_hid_BULLETIN_TEXT_EN").val());
                    $("#MainContent_txt_BULLETIN_TEXT").val(_BULLETIN_TEXT);
                    $("span[id*='lbl_text']").text("(waring：the max lenght is 100) ");
                    
                }
            });
        });
        
    </script>
</asp:Content>
